﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PokeTD
{
    class UIMessage
    {
        private string _text;
        private Color _color;
        private double _displaytime;
        private double _fadetime;
        private double _ofadetime;

        public string Text
        {
            get { return _text; }
        }

        public Color Color
        {
            get { return _color; }
        }

        public double DisplayTime
        {
            get { return _displaytime; }
        }

        public double FadeTime
        {
            get { return _fadetime; }
        }
        private SpriteFont _fnt;

        public UIMessage(string text, Color color, double displaytime, double fadetime, SpriteFont fnt)
        {
            _text = text;
            _color = color;
            _displaytime = displaytime;
            _fadetime = fadetime;
            _ofadetime = fadetime;
            _fnt = fnt;
        }

        public void Draw(SpriteBatch sb, Vector2 RootVec)
        {
            sb.DrawString(_fnt, _text, RootVec, _color);
        }

        public void Update(GameTime gt)
        {
            if (_displaytime <= 0)
            {
                int alphachannel = ((int)_fadetime / (int)_ofadetime) * 255;
                _color.A = (byte)alphachannel;
            }
            else
            {
                _displaytime -= gt.ElapsedGameTime.Milliseconds;
            }
        }
    }
}
